const path = require('path')
const merge = require('webpack-merge')
const pkg = require('./package')

module.exports = {
  mode: 'universal',

  /*
  ** Headers of the page
  */
  env: {
    BASE_URL: process.env.BASE_URL,
    NODE_ENV: process.env.NODE_ENV,
	HOST: process.env.HOST,
	PORT: process.env.PORT
  },
  server: {
    port: process.env.PORT, // default: 3000
	host: process.env.HOST
  },
  head: {
    title: pkg.name,
    meta: [
      {charset: 'utf-8'},
      {name: 'viewport', content: 'width=device-width, initial-scale=1'},
      {hid: 'description', name: 'description', content: pkg.description}
    ],
    link: [
      {rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}
    ]
  },

  /*
  ** Customize the progress-bar color
  */
  loading: {color: '#fff'},

  /*
  ** Global CSS
  */
  css: [
    'element-ui/lib/theme-chalk/reset.css',
    'element-ui/lib/theme-chalk/index.css',
    // 'assets/css/index.styl',
    'assets/fontawesome/css/fontawesome.min.css',
    'assets/myTools/myAtomCss/index.styl'
    // 'assets/css/myatom.styl'
  ],

  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
    '@/plugins/element-ui',
    '@/plugins/global-components'
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios'
  ],
  /*
  ** Axios module configuration
  */
  axios: {
    // See https://github.com/nuxt-community/axios-module#options
	//baseURL: 'http://localhost:3002'
	//baseURL: 'http://47.93.222.249:3002'
	//baseURL: 'http://127.0.0.1:3002'
	 baseURL: process.env.BASE_URL
  },
	
  /*
  ** Build configuration
  */
  build: {
    transpile: [/^element-ui/],
    cache: false,

    /* You can extend webpack config here */
    extend: function (config, ctx) {

      /* Run ESLint on save
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
      */
      config.resolve = merge(config.resolve, {
        alias: {
          'components': path.resolve(__dirname, 'components'),
          'assets': path.resolve(__dirname, 'assets'),
          'pages': path.resolve(__dirname, 'pages'),
          'http': path.resolve(__dirname, 'http'),
          'utils': path.resolve(__dirname, 'utils'),
          'store': path.resolve(__dirname, 'store')
        }
      })

      config.module.rules.push({
        test: /\.coffee$/,
        use: ['coffee-loader']
      })

      // config.module.rules.push(
    }
  }
}